home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
os2tools
/
bnklysrc
/
b_bbs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-03-11
|
9KB
|
260 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software <no-Inc> */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / No-Cost<no-tm> Software. */
/* \ 1011 / */
/* ------ */
/* */
/* Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello */
/* */
/* */
/* This module was written by Vince Perriello */
/* */
/* */
/* BinkleyTerm BBS / UUCP Session Initiator */
/* */
/* */
/* For complete details of the licensing restrictions, please refer */
/* to the License agreement, which is published in its entirety in */
/* the MAKEFILE and BT.C, and also contained in the file LICENSE.210. */
/* */
/* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
/* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
/* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
/* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT THE AUTHORS */
/* AT THE ADDRESSES LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO */
/* USE THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE */
/* BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU */
/* ARE ABLE TO REACH WITH THE AUTHORS. */
/* */
/* */
/* The Authors can be reached at the following addresses: */
/* */
/* Robert C. Hartman Vincent E. Perriello */
/* Spark Software VEP Software */
/* 427-3 Amherst Street 111 Carroll Street */
/* CS2032, Suite 232 Naugatuck, CT 06770 */
/* Nashua, NH 03061 */
/* */
/* FidoNet 1:132/101 FidoNet 1:141/491 */
/* Data (603) 888-8179 Data (203) 729-7569 */
/* */
/* Please feel free to contact us at any time to share your comments */
/* about our software and/or licensing policies. */
/* */
/*--------------------------------------------------------------------------*/
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
#include <conio.h>
#include <string.h>
#include <process.h>
#define WAZOO_SECTION
#define MATRIX_SECTION
#include "com.h"
#include "xfer.h"
#include "zmodem.h"
#include "keybd.h"
#include "sbuf.h"
#include "sched.h"
#include "externs.h"
#include "prototyp.h"
void BBSexit ()
{
int retval;
int xit = 0;
char command[80];
FILE *bbsbatch;
long t1, t2;
if (BBSnote != NULL)
{
sendbanner ("\r\n"); /* Start with newline */
sendbanner (BBSnote); /* Tell user we're going */
sendbanner ("\r\n"); /* End it with a newline */
}
t1 = timerset (50);
t2 = timerset (400);
/* Wait for output complete, 4 seconds, or carrier loss */
while (!OUT_EMPTY () && !timeup (t2) && CARRIER)
;
/* Make sure we waited at least 1/2 second */
while (CARRIER && !timeup (t1))
;
/* Now if there is no carrier bag it */
if (!CARRIER)
{
status_line ("!Lost Caller");
return;
}
++hist.bbs_calls;
sb_move (historywin, HIST_BBS_ROW, HIST_COL);
sprintf (junk, "%d/%d", hist.bbs_calls, hist.mail_calls);
sb_puts (historywin, junk);
if (strnicmp (BBSopt, "batch", 5) == 0) /* if BBS flag is "batch" */
{
strcpy (command, "BBSBATCH.BAT"); /* Batch file name */
unlink (command); /* Delete old copies */
if ((bbsbatch = fopen (command, "a")) == NULL) /* Try to open it */
{
status_line ("!Couldn't open BBSBATCH.BAT");
return;
}
errno = 0;
fprintf (bbsbatch, "SPAWNBBS %u %d %d %s\n",
cur_baud, port_ptr + 1, time_to_next (), mdm_reliable);
fclose (bbsbatch);
if (errno)
{
status_line ("!Trouble writing BBSBATCH.BAT");
return;
}
xit = 1;
}
if ((strnicmp (BBSopt, "exit", 4) == 0) || (xit)) /* "exit" or "batch" ?? */
{
retval = cur_baud / 100;
status_line (":Exiting to BBS with Errorlevel %u", retval);
if (vfossil_installed)
vfossil_close ();
if (!share) /* Turn off FOSSIL, */
MDM_DISABLE (); /* if need be */
write_sched ();
exit (retval); /* and exit with error */
}
if (strnicmp (BBSopt, "spawn", 5) == 0) /* if BBS flag is "spawn" */
{
status_line (":Spawning BBS");
gotoxy (0, 23);
sprintf (command, "SPAWNBBS %u %d %d %s",
cur_baud, port_ptr + 1, time_to_next (), mdm_reliable);
close_up ();
/* Run the BBS */
b_spawn (command);
come_back ();
status_line (":Returned from BBS");
}
}
void close_up ()
{
if (!share)
MDM_DISABLE ();
vfossil_close ();
/* Close the log file */
if (status_log != NULL)
fclose (status_log);
}
void come_back ()
{
/* Re-enable ourselves */
if (Cominit (port_ptr) != 0x1954)
{
cprintf ("\r\nDarn! The FOSSIL seems to have gone away! Exiting\r\n");
exit (1);
}
if (status_log != NULL)
{
if ((status_log = fopen (log_name, "at")) == NULL)
{
cprintf ("\r\nCannot re-open logfile\r\n");
}
}
MDM_ENABLE (btypes[baud].rate);
vfossil_init ();
if (fullscreen && un_attended)
{
scr_printf ("\033[H\033[2J");
sb_dirty ();
opening_banner ();
mailer_banner ();
sb_show ();
}
}
void UUCPexit (n)
int n; /* UUCP Errorlevel value */
{
char command[80];
FILE *mailbatch;
long t1, t2, timerset ();
if (MAILnote != NULL)
{
sendbanner ("\r\n"); /* Start with newline */
sendbanner (MAILnote); /* Say it's mail time */
sendbanner ("\r\n"); /* End with a newline */
}
t1 = timerset (50);
t2 = timerset (400);
/* Wait for output complete, 4 seconds, or carrier loss */
while (!OUT_EMPTY () && !timeup (t2) && CARRIER)
;
/* Make sure we waited at least 1/2 second */
while (CARRIER && !timeup (t1))
;
/* Now if there is no carrier bag it */
if (!CARRIER)
{
status_line ("!Lost Caller");
return;
}
strcpy (command, "MAILBAT.BAT"); /* Batch file name */
unlink (command); /* Delete old copies */
if ((mailbatch = fopen (command, "a")) == NULL) /* Try to open it */
{
status_line ("!Couldn't open MAILBAT.BAT");
return;
}
errno = 0;
fprintf (mailbatch, "EXTMAIL %u %d %d %d %s\n",
cur_baud, port_ptr + 1, time_to_next (), n, mdm_reliable);
fclose (mailbatch);
if (errno)
{
status_line ("!Trouble writing MAILBAT.BAT");
return;
}
status_line (":Exiting to external mailer with Errorlevel %u", n);
if (vfossil_installed)
vfossil_close ();
if (!share) /* Turn off FOSSIL, */
MDM_DISABLE (); /* if need be */
write_sched (); /* Save scheduler info */
exit (n); /* and exit with UUCP error */
}